package cc.vv.btpartyjob.partymanager.activity

import android.os.Message
import android.view.View
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.jnimodule.server.ResourceChooseServer
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.delegate.ManagerBaseBinder
import cc.vv.btpartyjob.partymanager.delegate.ProjectStatisticsActivityDelegate
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder

/**
 * 项目统计
 * Created by Chen.qi on 2018/10/30.
 */
class ProjectStatisticsActivity : BaseActivityMVP<ProjectStatisticsActivityDelegate>() {


    override fun initData() {
        viewDelegate?.setTopBarTitle("项目统计")
    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }
        })

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //开始时间
            ResourceChooseServer.chooseData(this, handler, 10)

        }, R.id.ll_aps_startQueryTime)

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //结束时间
            ResourceChooseServer.chooseData(this, handler, 11)

        }, R.id.ll_aps_endQueryTime)

    }

    override fun getDelegateClass(): Class<ProjectStatisticsActivityDelegate> {
        return ProjectStatisticsActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return ManagerBaseBinder()
    }

    override fun onHandleMsg(msg: Message?) {
        super.onHandleMsg(msg)
        when (msg?.what) {
            10 -> {
                val startTime = msg.obj as String
                viewDelegate?.setStartDateTime(startTime)
            }
            11 -> {
                val endTime = msg.obj as String
                viewDelegate?.setEndDateTime(endTime)
            }
        }
    }
}